function loadCasesFromList(handles)
%load cases from file and stores in the proper listBox

% This file is part of CISNE.
%
%     CISNE is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     any later version.
%
%     CISNE is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
%
%     You should have received a copy of the GNU General Public License
%     along with CISNE.  If not, see <http://www.gnu.org/licenses/>.

% Copyright 2011. Jose Maria Garcia-Valdecasas Bernal

% 21-Oct-09 ver. 1.0 (splitted from CISNE.m).


%write propagation cases in the listbox

projFolder=char(handles.SetupWidget.getValue('Project Folder'));
if ~exist(projFolder,'dir')
    projFolder='';
end

[fName,fPath] = uigetfile({'*.cls','(*.cls) CISNE Case List';...
                   '*.*','(*.*) All files'},'Select SWAN Cases File',projFolder);

file=fullfile(fPath,fName);

if exist(file,'file')
    fh1=fopen(file);
    n=0;
    while(~feof(fh1))
        line=fgetl(fh1);
        line=strtrim(line);
        if ~isempty(line)
            n=n+1;
            cases{n}=line; %#ok<AGROW>
        end
    end
    fclose(fh1);
    button=questdlg('Remove existing cases in project?','CISNE');
    if strcmp(button,'Yes')
        set(handles.LW_Cases,'String',cases);
    elseif strcmp(button,'No')
        oldcases=get(handles.LW_Cases,'String');
        cases{end+1:end+length(oldcases)}=oldcases;
        set(handles.LW_Cases,'String',cases);
    end
end
